var http = require('http')

var server = http.createServer()

server.on('request', function(req, res) {

    if (req.url === "/txt") {
        //Content-Type告诉浏览器文件类型，text/plain普通文本，charset="utf-8'utf-8编码
        res.setHeader('Content-Type', 'text/plain;charset="utf-8')

        res.end("我是普通文本")

    } else if (req.url === "/html") {
        res.setHeader('Content-Type', 'text/html;charset="utf-8')
        res.end("<h1>我是html便签</h1>")
    }

})

server.listen(3000)